package br.com.felix.fwt.ui;

import java.io.PrintWriter;

import br.com.felix.fwt.ui.exception.ComponentRenderException;

public class LinkButton extends BaseComponent{

	private static final long serialVersionUID = -5803289628240282130L;
	
	{
		this.cssClass = "fwtlinkbutton";
	}

	
	/**
	 * Instantiates a new link.
	 * @param text is the link's text.
	 * */
	public LinkButton(String text){
        super(text);
    }
	
	
	@Override
	public void write(PrintWriter out) throws ComponentRenderException {
		if(!authorized()) return;
		out.write("\n<a href=\"#\" ");
		if(actionListener!=null){
			actionListener.write(out);
		}
		if(style!=null){
			out.write(style);
		}
		String name = getName();
		if(name!=null){
			out.write(" id=\"");
			out.write(name);
			out.write("\" ");
		}
		out.write(">\n");
		out.write(getValue());
		out.write("\n</a>");
	}

}
